--- ejercicio con adventureWorks2012

select top(5) * from AdventureWorks2012.Person.Password
select top(5) * from AdventureWorks2012..Password

select * from AdventureWorks2012.sys.schemas
select * from AdventureWorks2012.sys.tables

select sc.name,ta.name
	from sys.tables	ta
	join sys.schemas sc on ta.schema_id=sc.schema_id


declare @tabla nvarchar(100)
		,@qry nvarchar(100)
		,@cant int
		--,@cantidad int
declare @temp table(nombre varchar(100),cantidad int)
declare qCont2 cursor for
	select (concat(sc.name,'.',QUOTENAME(ta.name)))
		from sys.tables	ta
		join sys.schemas sc on ta.schema_id=sc.schema_id
open qCont2
FETCH NEXT FROM qCont2 INTO @tabla
While @@FETCH_STATUS = 0
begin
	set @qry =N'select @cantidad= count(*) from ' + @tabla
	exec sp_executesql @qry,N'@cantidad int output',@cantidad=@cant output
	insert into @temp
		values(@tabla,@cant)
	FETCH NEXT FROM qCont2 INTO @tabla
END
select * from @temp